package com.nsl.my_youlai.bbu2.convert.apparatus_room;

import com.nsl.my_youlai.bbu2.enums.ApparatusRoomCategoryEnum;
import com.nsl.my_youlai.bbu2.enums.ApparatusRoomOwnershipEnum;
import com.nsl.my_youlai.bbu2.enums.CityEnum;
import com.nsl.my_youlai.bbu2.enums.YesNoEnum;
import com.nsl.my_youlai.bbu2.model.bo.ApparatusRoomBo;
import com.nsl.my_youlai.bbu2.model.vo.ApparatusRoomVoExcelString;
import com.nsl.my_youlai.mystar.easy_excel.NslUtilEasyExcel;
import com.nsl.my_youlai.mystar.enums.NslEnumBaseI;
import com.nsl.my_youlai.mystar.enums.NslEnumTransformException;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;



public class ApparatusRoomConverter {

    private static Map<String, String> prop2ExcelSheetHeadMap = NslUtilEasyExcel.getProp2ExcelSheetHeadMap(ApparatusRoomVoExcelString.class);

    static public ApparatusRoomBo toBo(ApparatusRoomVoExcelString vo) throws NslEnumTransformException {

        ApparatusRoomBo bo = new ApparatusRoomBo();
        bo.setId(Long.parseLong(vo.getRoomId()));
        bo.setCounty(vo.getCounty());
        bo.setLocation(vo.getLocation());


        CityEnum cityEnum = NslEnumBaseI.getEnumByLabel(vo.getCity(), CityEnum.class);
        bo.setCity(cityEnum);


        ApparatusRoomOwnershipEnum ownership = NslEnumBaseI.getEnumByLabel(vo.getOwnership(), ApparatusRoomOwnershipEnum.class);
        bo.setOwnership(ownership);


        ApparatusRoomCategoryEnum roomCategoryEnum = NslEnumBaseI.getEnumByLabel(vo.getRoomCategory(), ApparatusRoomCategoryEnum.class);
        bo.setRoomCategory(roomCategoryEnum);


        YesNoEnum yesNoEnum = NslEnumBaseI.getEnumByLabel(vo.getIsAnchorRoom(), YesNoEnum.class);
        bo.setAnchorRoom(yesNoEnum == YesNoEnum.YES);


        double longitude = Double.parseDouble(vo.getLongitude());
        bo.setLongitude(longitude);


        double latitude = Double.parseDouble(vo.getLatitude());
        bo.setLatitude(latitude);


        return bo;
    }

    static public List<ApparatusRoomBo> toBoList(List<ApparatusRoomVoExcelString> voList) throws NslEnumTransformException {
        List<ApparatusRoomBo> boList = new ArrayList<>(0);
        if (voList != null && voList.size() > 0) {
            List<ApparatusRoomBo> boList2 = new ArrayList<>(voList.size());
            for (ApparatusRoomVoExcelString vo : voList) {
                ApparatusRoomBo bo = toBo(vo);
                boList2.add(bo);
            }
            return boList2;
        }
        return boList;
    }


}
